/*
 * @Author: jingfuu@163.com
 * @Date: 2024-09-09 14:23:10
 * @LastEditTime: 2024-11-01 17:28:47
 * @Description: file content
 */
import { NestFactory } from '@nestjs/core';
import { AppModule } from './AppModule';
import { NestExpressApplication } from '@nestjs/platform-express';
import {
  DocumentBuilder,
  SwaggerDocumentOptions,
  SwaggerModule,
} from '@nestjs/swagger';

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);
  app.setViewEngine('ejs');
  app.enableCors({
    origin: '*',
    methods: '*',
    allowedHeaders: '*',
    exposedHeaders: '*',
    credentials: false, //为true,origin就不能设为*，设置为false通常不影响，因为跨域是手动设置的Authorization头
    maxAge: 3600,
  });
  const config = new DocumentBuilder()
    .setTitle('nest-single-start')
    .setDescription('The nest-single-start API description')
    .setVersion('1.0')
    .build();
  const options: SwaggerDocumentOptions = {
    operationIdFactory: (controllerKey: string, methodKey: string) => methodKey,
  };
  const document = SwaggerModule.createDocument(app, config, options);
  SwaggerModule.setup('api', app, document);
  await app.listen(3000);
}
bootstrap();
